<?php
//defined('BASEPATH') OR exit('No direct script access allowed');
//namespace core\admin;

class MY_Controller extends CI_Controller{
    function  __construct()
    {
        parent::__construct();
    }
}


class RM_Controller extends CI_Controller{

    public $reids = null;
    public $loginUid = 0;
    public $loginUser = null;

    public function __construct(){
        parent::__construct();
        $this->init();
    }

    public function init(){

        $this->loginCheck();

        $config = $this->config->item('redis');

        $redis = new Redis();
        $redis->connect($config['host'], $config['port']);

        if(!empty($config["auth"])){
            $redis->auth($config["auth"]);
        }

        $redis->select(isset($config['db']) ? $config['db'] : 0);

        $this->reids = $redis;
        $this->reids2 = $redis;
    }

    public function loginCheck(){

        session_start();
        $this->loginUid = isset($_SESSION["loginUid"]) ? $_SESSION["loginUid"] : 0;

        if($this->loginUid > 0){

            $user = \models\User::getUserById($this->loginUid);
            $this->loginUser = $user;

        }else{
            header("Location:"."/login.html");

        }
    }


}

?>